<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
    <title>地图显示</title>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
        }
        
        .dk {
            position: fixed;
            bottom: 30px;
            left: 0;
            width: 100%;
            text-align: center;
            z-index: 99999;
        }
        
        .dk span {
            /* display: block;
            width: 70px;
            height: 70px;
            line-height: 70px;
            border-radius: 50%;
            background-image: linear-gradient(#4a9aff, #9198e5);
            margin: 0 auto;
            color: #fff;
            font-size: 18px;
            font-weight: 400;
            cursor: pointer; */
        }
        
        .css-3d-btn {
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            /* background-color: rgba(219, 87, 51, 1); */
            background-image: linear-gradient(#4a9aff, #9198e5);
            font-family: "Microsoft YaHei", 微软雅黑, 宋体;
            font-weight: 500;
            font-size: 18px;
            display: block;
            padding: 4px;
            border-radius: 20px;
            /* let's use box shadows to make the button look more 3-dimensional */
            box-shadow: 0px 9px 0px #828bef, 0px 9px 25px rgba(0, 0, 0, .7);
            margin: 0 auto;
            width: 100px;
            height: 60px;
            line-height: 50px;
            user-select: none;
            text-align: center;
            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            transition: all .1s ease;
        }
        /* now if we make the box shadows smaller when the button is clicked, it'll look like the button has been "pushed" */
        
        .css-3d-btn:active {
            box-shadow: 0px 3px 0px #828bef, 0px 3px 6px rgba(0, 0, 0, .9);
            position: relative;
            top: 6px;
        }
    </style>
</head>

<body>
    <div class="dk"><span class="css-3d-btn">下班打卡</span></div>
    <div id="container"></div>
    <!-- 加载地图JSAPI脚本 -->
    <script src="https://webapi.amap.com/maps?v=1.4.15&key=11ddf83329ce12de0eafce4049ad66d7	"></script>
    <script>
        var map = new AMap.Map('mapBox2venue', {
            resizeEnable: true, //是否监控地图容器大小变化；值为布尔值，true为允许，false为不允许
        });
        AMap.plugin('AMap.Geolocation', function() {
            var geolocation = new AMap.Geolocation({
                //使用web浏览器进行精准定位，并返回定位结果；
                //注：下面的配置信息，可以去除谷歌定位默认的定位小圆圈；
                enableHighAccuracy: true, //是否使用高精度定位，默认:true
                timeout: 10000, //超过10秒后停止定位，默认：无穷大
                maximumAge: 0, //定位结果缓存0毫秒，默认：0
                convert: true, //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                showButton: true, //显示定位按钮，默认：true
                buttonPosition: 'LB', //定位按钮停靠位置，默认：'LB'，左下角
                buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                showMarker: false, //定位成功后在定位到的位置显示点标记，默认：true
                showCircle: false, //定位成功后用圆圈表示定位精度范围，默认：true  （去掉圆形区域）
                panToLocation: true, //定位成功后将定位到的位置作为地图中心点，默认：true
                zoomToAccuracy: false //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            });
            map.addControl(geolocation);
            geolocation.getCurrentPosition(function(status, result) {
                if (status == 'complete') {
                    console.log('====result====', result); // result为精准定位成功的返回结果；

                    maps = new AMap.Map('container', {
                        resizeEnable: true,
                        rotateEnable: true,
                        pitchEnable: true,
                        zoom: 18,
                        pitch: 60,
                        rotation: -15,
                        viewMode: '3D', //开启3D视图,默认为关闭
                        buildingAnimation: true, //楼块出现是否带动画

                        expandZoomRange: true,
                        zooms: [3, 20],
                        center: [result.position.lng, result.position.lat]
                    });
                    // var maps = new AMap.Map('container', {
                    //     resizeEnable: true, //是否监控地图容器尺寸变化
                    //     zoom: 18, //初始化地图层级
                    //     center: [result.position.lng, result.position.lat] //初始化地图中心点
                    // });
                    var marker = new AMap.Marker({
                        map: maps,
                        icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
                        position: [result.position.lng, result.position.lat]
                    });
                    var circle = new AMap.Circle({
                        map: maps,
                        center: [126.61358, 45.71265], //设置线覆盖物路径
                        radius: 60,
                        strokeColor: "#ddd", //边框线颜色
                        strokeOpacity: 0.3, //边框线透明度
                        strokeWeight: 3, //边框线宽
                        fillColor: "#999", //填充色
                        fillOpacity: 0.35 //填充透明度
                    });
                    // console.log(result.position.lng);
                } else {
                    console.log('=====error result ====', result); //如果status不等于'complete'，则定位失败；返回的result中包含失败信息；
                }
            })
        })
    </script>
</body>

</html>